﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="edit_event.aspx.cs" Inherits="SQT.tracnghiem.Ajax.ASP.Events.edit_event" %>

<%@ Import Namespace="DataAccess" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<body>
    <%
        int id = int.Parse(Request.QueryString["id"]);
        var get_event = new TblEventController().FetchAll().Single(x => x.Id == id);
    %>
    <header class="w3-center w3-padding-4">
        <label>Sửa sự kiện</label>
    </header>
    <div class="w3-row w3-padding">
        <label class="w3-col l2">Tên sự kiện</label><input id="edit_event_name" value="<%=get_event.Name %>" type="text" class="game-text w3-light-grey w3-col l10" />
    </div>
    <div class="w3-row w3-padding">
        <label class="w3-col l2">Người chơi</label>
        <div style="height: 300px; overflow: auto" class="w3-col l9 w3-center">
            <table id="edit_player_added" class="w3-center" style="width: 100%">
                <tr class="w3-teal">
                    <td style="padding: 0.8% 0.5%">Ảnh</td>
                    <td style="padding: 0.8% 0.5%">Tên đăng nhập</td>
                    <td style="padding: 0.8% 0.5%">Tên đội</td>
                    <td style="padding: 0.8% 0.5%">Đổi tên đội</td>
                </tr>
                <%if (get_event.Players != "")
                    {
                        string[] split = get_event.Players.Split(',');
                        for (int i = 0; i < split.Length-1; i++)
                        {
                            var get_player = new TblUserController().FetchAll().Single(x => x.UserId == int.Parse(split[i]));
                %>
                <tr style="border-bottom: solid 1px #ddd">
                    <td style="padding: 0.8% 0.5%">
                        <img src="../Content/avatar/<%=get_player.Avatar %>" style="width: 50px; height: 50px" class="w3-circle" /></td>
                    <td style="padding: 0.8% 0.5%"><%=get_player.UserName %></td>
                    <td style="padding: 0.8% 0.5%"><%=get_player.FullName %></td>
                    <td style="padding: 0.8% 0.5%"><i onclick="btn_change_name(<%=get_player.UserId %>,'<%=get_player.FullName %>')" style="cursor: pointer" class="fa fa-user"></i></td>
                </tr>
                <%}
                } %>
            </table>
        </div>
        <a title="Thêm người chơi" onclick="btn_add_player()" class="game-review-img-btn w3-btn w3-teal w3-col l1"><i class="fa fa-calendar-plus-o"></i></a>
    </div>
    <div class="w3-row w3-padding">
        <label class="w3-col l2">Thứ tự trò chơi</label>
        <div class="w3-row w3-col l9 w3-light-grey w3-center">
            <table class="volca-table w3-table w3-striped w3-bordered w3-white">
                <tbody id="sortable_add_game" class="ui-sortable">
                    <%var get_plan = new TblEventPlanController().FetchAll().Where(x=>x.EventId==id);
                      foreach (TblEventPlan events in get_plan){
                        var get_game = new TblEventGameController().FetchAll().Single(x=>x.Id == events.GamesType);
                         %>
                    <tr id="edit_add_games_<%=events.GamesType %>" class="ui-state-default ui-sortable-handle" onclick="edit_show_question(<%=events.GamesType %>,<%=id %>)">
                        <td class="edit_add_game_id w3-hide"><%=events.GamesType %></td>
                        <td class="w3-hide edit_games_content_id"><%=events.GamesId %></td>
                        <td class="w3-hide edit_games_content_time"><%=events.GamesTime %></td>
                        <td class="w3-hide edit_games_content_score"><%=events.GamesScore %></td>
                        <td><%=get_game.Name %></td>
                    </tr>
                    <%} %>
                </tbody>
            </table>
        </div>
    </div>
    <div class="w3-row w3-padding w3-center">
        <a onclick="btn_edit_event(<%=id %>)" class="w3-btn w3-teal"><i class="fa fa-check"></i>&nbsp;Xác nhận</a>
    </div>
    <div class="w3-hide" id="player_added_hidden"><%=get_event.Players %></div>
</body>
</html>
